function SampleInfo = LoadProfilesSampler(LoadProfilePaths, num_samples)
    %LoadProfilesSampler 对输入曲线进行抽样
    %   LoadProfilePaths，每条csv曲线的路径
    %   num_samples，采样数量

    %% default arguments
    info = 0;

    if ~exist('LoadProfilePaths', 'var')
        info = 1;
    else

        if isa(LoadProfilePaths, 'cell')
            LoadProfilePaths = string(LoadProfilePaths);
            Paths_input_type = 2;
        elseif isa(LoadProfilePaths, 'string')
            Paths_input_type = 1;
        end

        if isvector(LoadProfilePaths) || isscalar(LoadProfilePaths)
            SampleInfo.LoadProfilePaths = LoadProfilePaths;
            SampleInfo.Nprofile = length(LoadProfilePaths);
            Nprofile = length(LoadProfilePaths);
        else

            if Paths_input_type == 2
                info = 4;
            else
                info = 3;
            end

        end

    end

    if ~exist('num_samples', 'var')
        SampleInfo.num_samples = [];
        num_samples = [];
        Nsample = 0;
    else

        if isscalar(num_samples) || isvector(num_samples)
            SampleInfo.num_samples = num_samples;
            SampleInfo.Nsample = length(num_samples);
            Nsample = length(num_samples);
        else
            info = 2;
        end

    end

    %% 加载曲线数据
    SampleInfo.profiles = struct('time',{},'mult',{});

    for k = 1:Nprofile
        file_name = LoadProfilePaths(k);
        opt = detectImportOptions(file_name, 'PreserveVariableNames', true);
        opt = setvartype(opt, {'time'}, 'duration');
        opt = setvaropts(opt, {'time'}, 'InputFormat', 'hh:mm:ss');
        T = readtable(file_name, opt);
        SampleInfo.profiles(k) = table2struct(T, 'ToScalar', true);
    end

    %% 数据抽样
    if Nsample >= 1
        SampleInfo.choices = cell(Nsample, 1);

        for k = 1:Nsample
            SampleInfo.choices{k} = floor(rand(1, num_samples(k)) * Nprofile) + 1;
        end

    else
        SampleInfo.choices = [];
    end

    %% 错误处理
    if info == 0 % % no errors

    else % % we have a problem captain

        switch info
            case 1
                error('Sample:需指定采样曲线路径或输入采样数据格式');
            case 2
                error('Sample: 采样数必须为标量或向量');
            case 3
                error('Sample: 路径字符串不能为矩阵');
            case 4
                error('Sample: 路径字符元胞数组不能为矩阵');
            case 5
                error('loadcase: syntax error or undefined data matrix(ices) in the file\n%s', 'test');
            otherwise
                error('loadcase: unknown error');
        end

    end
